import { BaseEntity } from "./../common/base.schema";
import * as moment from "moment";
import { Schema, Prop, SchemaFactory } from "@nestjs/mongoose";
import { IsNotEmpty } from "class-validator";
import { KWCode } from "../common/code";
import { Document } from "mongoose";

export type BookDocument = Book & Document;

export class Book extends BaseEntity {
  @IsNotEmpty({ message: '图书名称不能为空', context: { errorCode: KWCode.invalidInput } })
  @Prop({ required: true, type: String })
  name: string;

  @Prop()
  public desc?: string;

  @Prop()
  public author?: string;
}

export const BookSchema = SchemaFactory.createForClass(Book);
